package log;

public abstract class LogParser
{
    public interface ILogParserCallback {
        void OnLogItem(LogItem item);
    }

    public abstract void parse(String line) throws Exception;

    public abstract void flush();

    public void setCallback(ILogParserCallback callback) {
        _parserCallback = callback;
    }

    protected void doOnLogItem(LogItem item) {
        item.index = _logIndex++;
        if (_parserCallback != null) {
            _parserCallback.OnLogItem(item);
        }
    }

    private ILogParserCallback _parserCallback;
    private int _logIndex = 1;

}
